package com.leapp;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class BdHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 1;
	public static final String TABLE_NAME = "questionario";
	private static final String DATABASE_NAME = "questionarios.db";
	
	public static final String ID = "_id";
	public static final String ENUNCIADO = "enunciado";
	public static final String RESPOSTA = "resposta";

	private static final String DATABASE_CREATE = "create table "
			+ TABLE_NAME + "( " + ID
			+ " integer primary key autoincrement, " + ENUNCIADO
			+ " text not null, " + RESPOSTA + " text);";
	
	public BdHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		//super()
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(BdHelper.class.getName(), "Upgrading database from version " + oldVersion + " to "	+ newVersion + ", which will destroy all old data");
	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
	}
}

